package com.zh.note.huawei.onehundred.简易压缩算法;

/**
 * @Author: zhanghuan
 * @date: 2023/9/1 13:28
 * @description: create it
 */

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String input = scanner.nextLine();
        StringBuilder sb = new StringBuilder();
        int currentNumber = -1;
        int length = input.length();

        for (int i = 0; i < length; i++) {
            char c = input.charAt(i);
            if (Character.isDigit(c)) { //判处当前遍历的字符是否是数字
                int digit = c - '0';
                if (i == length - 1) {// 数字不能出现在最后一位
                    sb = new StringBuilder("!error");
                    break;
                } else if (currentNumber == -1) {
                    if (digit == 0 || (digit < 3 && digit > 0 && Character.isLowerCase(input.charAt(i + 1)))) {
                        sb = new StringBuilder("!error");
                        break;
                    } else {
                        currentNumber = digit;
                    }
                } else {
                    currentNumber = currentNumber * 10 + digit;
                }
            } else if (Character.isLowerCase(c)) { // 判断当前字符是否是小写字母
                if (currentNumber >= 3) {
                    if (i != length - 1 && c == input.charAt(i + 1)) {
                        sb = new StringBuilder("!error");
                        break;
                    }
                    for (int j = 0; j < currentNumber; j++) {
                        sb.append(c);
                    }
                    currentNumber = -1;
                } else {
                    if (i < length - 2 && c == input.charAt(i + 1) && c == input.charAt(i + 2)) {
                        sb = new StringBuilder("!error");
                        break;
                    }
                    sb.append(c);
                }
            } else { // 当前遍历的不是字母也不是数字
                sb = new StringBuilder("!error");
                break;
            }
        }
        System.out.println(sb);
    }
}

